import Vue from 'vue'
import App from './App.vue'
import router from './router'
import request from './utils/request.js'
/* import axios from 'axios'
Vue.use(axios); */
/* toast属于函数，全局注册后自动挂载到Vue原型中 */
import { Toast } from 'vant';
import { Notify } from 'vant';
import { Image as VanImage } from 'vant';
import { Dialog } from 'vant';
import { NavBar } from 'vant';
import { Uploader } from 'vant';
import { Field } from 'vant';
import { ActionSheet } from 'vant';
import { Tab, Tabs } from 'vant';
import { List } from 'vant';
import { PullRefresh } from 'vant';
import { Button } from 'vant';
import { SwipeCell } from 'vant';
import { Empty } from 'vant';
import { Icon } from 'vant';
import { Search } from 'vant';
import { Popup } from 'vant';
import { Cell, CellGroup } from 'vant';

Vue.use(Cell);
Vue.use(CellGroup);
Vue.use(Popup);
Vue.use(Search);
Vue.use(Icon);
Vue.use(Empty);
Vue.use(SwipeCell);
Vue.use(Button);
Vue.use(PullRefresh);
Vue.use(List);
Vue.use(Tab);
Vue.use(Tabs);
Vue.use(ActionSheet);
Vue.use(Field);
Vue.use(Uploader);
Vue.use(NavBar);
Vue.use(VanImage);
Vue.use(Toast);  
Vue.use(Notify);
Vue.use(Dialog);  

/* 初始化样式 */
import './styles/reset.less'
/* 引入iconfont */
import './styles/IconFont.css'
import defaultImg from './assets/logo.png'
Vue.config.productionTip = false

//全局过滤器
Vue.filter('imgUrl', (val) => {
	if(!val){
		return defaultImg;
	}else if(val.indexOf('http') === -1){
		return request.defaults.baseURL + val;
	}else{
		return val;
	}
})
Vue.filter('formatDate', (val) => {
	if(val){
		return val.replace('T' , ' ').replace('.000Z' , ' ')
	}
})

//全局指令
Vue.directive('focus' , {
	/* inserted组件或标签插入到页面时触发 */
	update (el){
		console.log(el);
		el.focus();
	}
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
